/**
 * Copyright 2010 Philippe Beaudoin
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.philbeaudoin.gwtptabsample.client.gin;

import com.google.inject.Singleton;
import com.philbeaudoin.gwtp.mvp.client.DefaultEventBus;
import com.philbeaudoin.gwtp.mvp.client.EventBus;
import com.philbeaudoin.gwtp.mvp.client.RootPresenter;
import com.philbeaudoin.gwtp.mvp.client.gin.AbstractPresenterModule;
import com.philbeaudoin.gwtp.mvp.client.proxy.ParameterTokenFormatter;
import com.philbeaudoin.gwtp.mvp.client.proxy.PlaceManager;
import com.philbeaudoin.gwtp.mvp.client.proxy.ProxyFailureHandler;
import com.philbeaudoin.gwtp.mvp.client.proxy.ProxyRaw;
import com.philbeaudoin.gwtp.mvp.client.proxy.TokenFormatter;
import com.philbeaudoin.gwtptabsample.client.FailureHandlerAlert;
import com.philbeaudoin.gwtptabsample.client.GwtptabsamplePlaceManager;
import com.philbeaudoin.gwtptabsample.client.presenter.AboutUsPresenter;
import com.philbeaudoin.gwtptabsample.client.presenter.ContactPresenter;
import com.philbeaudoin.gwtptabsample.client.presenter.HomeInfoPresenter;
import com.philbeaudoin.gwtptabsample.client.presenter.HomeNewsPresenter;
import com.philbeaudoin.gwtptabsample.client.presenter.HomePresenter;
import com.philbeaudoin.gwtptabsample.client.presenter.MainPagePresenter;
import com.philbeaudoin.gwtptabsample.client.view.AboutUsView;
import com.philbeaudoin.gwtptabsample.client.view.ContactView;
import com.philbeaudoin.gwtptabsample.client.view.HomeInfoView;
import com.philbeaudoin.gwtptabsample.client.view.HomeNewsView;
import com.philbeaudoin.gwtptabsample.client.view.HomeView;
import com.philbeaudoin.gwtptabsample.client.view.MainPageView;

/**
 * @author Christian Goudreau
 */
public class ClientModule extends AbstractPresenterModule {
	@Override
	protected void configure() {
	  //Singletons
		bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
		bind(PlaceManager.class).to(GwtptabsamplePlaceManager.class).in(Singleton.class);
		bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
    bind(RootPresenter.class).asEagerSingleton();
    bind(ProxyFailureHandler.class).to(FailureHandlerAlert.class).in(Singleton.class);
    
    //Presenters
    bind(ProxyRaw.class).annotatedWith(DefaultPlace.class).to(HomeNewsPresenter.MyProxy.class);
    bindPresenter(MainPagePresenter.class, MainPagePresenter.MyView.class, MainPageView.class, MainPagePresenter.MyProxy.class);
    bindPresenter(HomePresenter.class, HomePresenter.MyView.class, HomeView.class, HomePresenter.MyProxy.class);
    bindPresenter(AboutUsPresenter.class, AboutUsPresenter.MyView.class, AboutUsView.class, AboutUsPresenter.MyProxy.class);
    bindPresenter(ContactPresenter.class, ContactPresenter.MyView.class, ContactView.class, ContactPresenter.MyProxy.class);
    bindPresenter(HomeNewsPresenter.class, HomeNewsPresenter.MyView.class, HomeNewsView.class, HomeNewsPresenter.MyProxy.class);
    bindPresenter(HomeInfoPresenter.class, HomeInfoPresenter.MyView.class, HomeInfoView.class, HomeInfoPresenter.MyProxy.class);
	}
}